package com.qzsoft.system.modules.permission.group.service.impl;

import com.qzsoft.jeemis.common.service.BaseService;
import com.qzsoft.system.modules.permission.group.dao.SysGroupDao;
import com.qzsoft.system.modules.permission.group.dao.SysUserGroupDao;
import com.qzsoft.system.modules.permission.group.dto.SysGroupDTO;
import com.qzsoft.system.modules.permission.group.dto.SysGroupRoleDTO;
import com.qzsoft.system.modules.permission.group.service.SysUserGroupService;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 用户与用户组信息(sys_user_group)表服务实现类
 */
@Service("sysUserGroupService")
@Log4j2
public class SysUserGroupServiceImpl extends BaseService implements SysUserGroupService {

    @Autowired
    private SysUserGroupDao sysUserGroupDao;
    @Autowired
    private SysGroupDao sysGroupDao;
    @Override
    public List<SysGroupDTO> getGroupList(Long id) {
        List<SysGroupDTO> list=  sysUserGroupDao.getGroupList(id);
        for(SysGroupDTO sgd:list){
            List<SysGroupRoleDTO>  roleList=sysGroupDao.selectDefaultList(sgd.getId());
            if(roleList != null && !roleList.isEmpty()){
                sgd.setRoleList(roleList);
            }
        }
        return list;
    }

}